package com.tansuo365.test1.controller.othercontrol;

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("")
public class ViewsController {

    @RequestMapping("")
    public String index(){
        return "main.html";
    }

    //路径配置.后期调整近菜单
    @RequestMapping("/path")
    public String path(){
        return "ukzqmooc/pathurl";
    }

    /**
     * 注册账号,后期dele
     * @return
     */
    @GetMapping("/admin/reg")
    public String reg(){
        return "reg";
    }

    /**
     * 加载当前用户信息
     * @param session
     * @return
     * @throws Exception
     */
    @ResponseBody
    @GetMapping("/admin/loadUserInfo")
    public String loadUserInfo(HttpSession session)throws Exception{
        String truename =(String) session.getAttribute("truename");
        return "欢迎您："+truename+".";
    }
    /**
     * 安全退出
     * @return
     * @throws Exception
     */
    @GetMapping("/admin/logout")
//    @RequiresPermissions(value = { "安全退出" })
    public String logout()throws Exception{
        SecurityUtils.getSubject().logout();
        return "redirect:/login";
    }
}
